<?php
/**
 *
 * public function actions() {
 *       return array(
 *           'newsletter' => array(
 *               'class' => 'application.widgets.newsletter.ANewsletter'
 *           )
 *       );
 *   }
 * @author Tuong Tran <tuong.tran@outlook.com>
 */
class ANewsletter extends CAction{
    public function run() {
        //import model
        //Yii::import('common.models.subscriber.*');
        if(r()->isPostRequest){
            $model = new Subscriber();
            $model->email = $_POST['email'];

            if($model->save()){
                echo json_encode(array(
                    'result' => TRUE
                ));
            }else{
                echo json_encode(array(
                    'result' => FALSE,
                    'error' => $model->getErrors()
                ));
            }
        }

        app()->end();
    }
}
